

package jetbrains.buildServer.server.rest.data.problem.scope;

import java.util.List;
import jetbrains.buildServer.serverSide.STestRun;
import jetbrains.buildServer.util.filters.Filter;
import org.jetbrains.annotations.NotNull;

public class TestScopeFilterImpl implements TestScopeFilter {
  public static final String[] SUPPORTED_DIMENSIONS = {"suite", "package", "class", "buildType", "affectedProject"};

  @NotNull
  private final List<Filter<STestRun>> myConditions;
  @NotNull
  private final String myLocatorString;

  public TestScopeFilterImpl(@NotNull List<Filter<STestRun>> conditions, @NotNull String locatorString) {
    myConditions = conditions;
    myLocatorString = locatorString;
  }

  @NotNull
  @Override
  public String getLocatorString() {
    return myLocatorString;
  }

  @Override
  public boolean test(@NotNull STestRun item) {
    return myConditions.stream().allMatch(f -> f.accept(item));
  }
}